/* Copyright (C) 2014 TU Dortmund
 * This file is part of LearnLib-TTT, https://github.com/LearnLib/learnlib-ttt/
 * 
 * LearnLib-TTT is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * LearnLib-TTT is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with LearnLib-TTT.  If not, see <http://www.gnu.org/licenses/>.
 */
package de.learnlib.algorithms.ttt.mealy.it;

import de.learnlib.examples.LearningExample.MealyLearningExample;
import de.learnlib.algorithms.ttt.aut.AUTImporter;
import net.automatalib.automata.transducers.MealyMachine;
import net.automatalib.automata.transducers.impl.compact.CompactMealy;
import net.automatalib.words.Alphabet;

import java.io.IOException;
import java.io.InputStream;

public class RealisticSystem implements MealyLearningExample<String,String> {
	
	private final String name;
	private final CompactMealy<String, String>  model;
	
	public RealisticSystem(String name, int type) throws IOException {
		this.name = name;
		if(type==0) {
			try (InputStream is = RealisticSystem.class.getResourceAsStream("/" + name + ".mealy")) {
				this.model = AUTImporter.readMealy(is);
			}
		}
		else
		{
			this.model = AUTImporter.readDot(name + ".dot");
		}
	}

	@Override
	public CompactMealy<String, String> getReferenceAutomaton() {
		return model;
	}

	@Override
	public Alphabet<String> getAlphabet() {
		return model.getInputAlphabet();
	}
	
	@Override
	public String toString() {
		return name;
	}

}